var u = navigator.userAgent;
var isAndroid = u.indexOf('Android') > -1 || u.indexOf('Adr') > -1; //android终端
var isiOS = !!u.match(/\(i[^;]+;( U;)? CPU.+Mac OS X/); //ios终端
let layout = {};
layout = {
    //1.去绑定微信
    MJWXBinding:function(){
        if(isiOS)
            window.webkit.messageHandlers.MJWXBinding.postMessage(null)
        else
            window.androidJs.jumpToBindWeChatPage();
    },
    //2.去首页
    MJGoHome:function(){
        if(isiOS)
            window.webkit.messageHandlers.MJGoHome.postMessage(null) 
        else
            window.androidJs.jumpToVideoHomePage();
    },
   // 3.打开微信
    MJWXOpen:function(){
        if(isiOS)
            window.webkit.messageHandlers.MJWXOpen.postMessage(null) 
        else
            window.androidJs.openWechatApp();

    },
    //4.去登录
    MJLogin:function(){
        if(isiOS)
            window.webkit.messageHandlers.MJLogin.postMessage(null)
        else
           window.androidJs.jumpToLoginPage(); 
    },
    //5.分享
    MJShare:function(data){
        let type = data.type,/// 1 朋友圈 2 微信好友 3 QQ空间  4 QQ好友
            url = data.url,
            title = data.title||"待传",
            content = data.content||"待传",
            imgUrl = data.imgUrl||'';
        if(isiOS){
            window.webkit.messageHandlers.MJShare.postMessage({platformType:type,url:url})  
        }
        else{
            if (type == 1) {
                window.androidJs.shareToWechatMoments(title,content,url,imgUrl);   
            }else if(type == 2){
                window.androidJs.shareToWechat(title,content,url,imgUrl);   
            }else if(type == 3){

            }else if( type == 4){
                window.androidJs.shareToQq(title,content,url,imgUrl)
            }
        }
    },
    //6.返回app
    NativeBack:function(){
        if(isiOS)
            window.webkit.messageHandlers.NativeBack.postMessage(null)
    },
    //7 打开编辑资料页
    MJEdit:function(){
        if(isiOS)
           console.log('ios MJEdit')
        else 
            window.androidJs.startActivityToEditPersonalProfile()
    }
    
}
window.H5brigeAPP = layout;

//兼容安卓尾部高度
// if (isAndroid) {
//     var isFoot = $('.footer').length();
//     if (isFoot>0) {
//         $('.footer').css('paddingBottom','100px');
//     }
// }

